<template>
  <div>
    <!-- 选择开设专业 -->
    <el-select
      v-model="value"
      collapse-tags
      @change="handleChange"
      placeholder="请选择"
      style="width: 100%"
    >
      <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.name"
        :value="item.code"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { eduMajorsQuery } from "@/api/admin/teach/eduMajors.js";
export default {
  data() {
    return {
      value: [],
      options: [],
      listQuery: {
        page: 1,
        limit: 10,
        pid: 0,
      },
    };
  },
  props: ["defaultValue"],
  watch: {
    defaultValue(v) {
      this.value = v;
    },
  },
  mounted() {
    this.value = this.defaultValue;
    this.getList();
  },
  methods: {
    getList() {
      eduMajorsQuery(this.listQuery).then((res) => {
        this.options = res.data.data;
      });
    },
    handleChange(value) {
      this.$emit("emit", value);
    },
  },
};
</script>